//
//  VistorView.swift
//  WBSwift
//
//  Created by maker on 2016/11/9.
//  Copyright © 2016年 maker. All rights reserved.
//

import UIKit

class VistorView: UIView {
    
    //提供一个类方法来从 xib 中创建 view
    class func creatXib() -> VistorView{
       return Bundle.main.loadNibNamed("VistorView", owner: nil, options: nil)?.first as! VistorView
    }
    
    //MARK:========== UI 控件 ==========
    @IBOutlet weak var rotationView: UIImageView!
    @IBOutlet weak var tipLabel: UILabel!
    @IBOutlet weak var icon: UIImageView!
    @IBOutlet weak var registerBtn: UIButton!
    @IBOutlet weak var loginBtn: UIButton!
    
    
    func setInfo(_ iconName:String,tip:String) {
        tipLabel.text = tip
        icon.image = UIImage(named: iconName)
        rotationView.isHidden = true
    }
    
    func startRotationAnimation() {
        //1.创建动画
        let rotation = CABasicAnimation(keyPath: "transform.rotation.z")
    
        //2.设置动画的属性
        rotation.fromValue = 0
        rotation.toValue = M_PI * 2
        rotation.duration = 6
        rotation.repeatCount = MAXFLOAT
        rotation.isRemovedOnCompletion = false
        
        //3.给控件的 layer 添加动画
        rotationView.layer .add(rotation, forKey: nil)
    }
}
